package com.qgs.secsgem.mq.configuration;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Desc: "设备：PID24a 相关信息定义"
 * @Author: caixiang
 * @DATE: 2021/6/7 9:11
 */
@Configuration
public class ConfigOfPID24a {

    //水平扩展其他设备的时候 只要：control+R 然后 PID24a=>00C  然后replace all
    public static final String EQUIPMENT_NAME_PID24a = "PID24a";

    public static final String EXCHANGE_NAME_PID24a = EQUIPMENT_NAME_PID24a +"_Exchange";
    public static final String EAP_REQUEST_QUEUE_PID24a = EQUIPMENT_NAME_PID24a +"_EAP_Request_Queue";
    public static final String EAP_RESPONSE_QUEUE_PID24a = EQUIPMENT_NAME_PID24a +"_EAP_Response_Queue";
    public static final String MES_REQUEST_QUEUE_PID24a = EQUIPMENT_NAME_PID24a +"_MES_Request_Queue";
    public static final String MES_RESPONSE_QUEUE_PID24a = EQUIPMENT_NAME_PID24a +"_MES_Response_Queue";
    public static final String EAP_REQUEST_QUEUE_ROUTINGKEY_PID24a = EQUIPMENT_NAME_PID24a +"_EAP_Request_Queue_RoutingKey";
    public static final String EAP_RESPONSE_QUEUE_ROUTINGKEY_PID24a = EQUIPMENT_NAME_PID24a +"_EAP_Response_Queue_RoutingKey";
    public static final String MES_REQUEST_QUEUE_ROUTINGKEY_PID24a = EQUIPMENT_NAME_PID24a +"_MES_Request_Queue_RoutingKey";
    public static final String MES_RESPONSE_QUEUE_ROUTINGKEY_PID24a = EQUIPMENT_NAME_PID24a +"_MES_Response_Queue_RoutingKey";


    @Bean
    public DirectExchange EXCHANGE_NAME_PID24a(){
        return new DirectExchange(EXCHANGE_NAME_PID24a);
    }

    //todo
    @Bean
    public Queue MES_REQUEST_QUEUE_PID24a(){
        Queue queue = new Queue(MES_REQUEST_QUEUE_PID24a);
        queue.addArgument("x-dead-letter-exchange",ConfigOfDeadLetterQueue.EXCHANGE_NAME_DLE);
        queue.addArgument("x-dead-letter-routing-key",ConfigOfDeadLetterQueue.Dead_Letter_RoutingKey);
        //queue.addArgument("x-max-priority",ConfigOfDeadLetterQueue.MAX_PRIORITY);
        return queue;
    }
    @Bean
    public Queue MES_RESPONSE_QUEUE_PID24a(){
        Queue queue = new Queue(MES_RESPONSE_QUEUE_PID24a);
        queue.addArgument("x-dead-letter-exchange",ConfigOfDeadLetterQueue.EXCHANGE_NAME_DLE);
        queue.addArgument("x-dead-letter-routing-key",ConfigOfDeadLetterQueue.Dead_Letter_RoutingKey);
        //queue.addArgument("x-max-priority",ConfigOfDeadLetterQueue.MAX_PRIORITY);
        return queue;
    }


    @Bean
    public Queue EAP_REQUEST_QUEUE_PID24a(){
        Queue queue = new Queue(EAP_REQUEST_QUEUE_PID24a);
        queue.addArgument("x-dead-letter-exchange",ConfigOfDeadLetterQueue.EXCHANGE_NAME_DLE);
        queue.addArgument("x-dead-letter-routing-key",ConfigOfDeadLetterQueue.Dead_Letter_RoutingKey);
        //queue.addArgument("x-max-priority",ConfigOfDeadLetterQueue.MAX_PRIORITY);
        return queue;

    }
    @Bean
    public Queue EAP_RESPONSE_QUEUE_PID24a(){
        Queue queue = new Queue(EAP_RESPONSE_QUEUE_PID24a);
        queue.addArgument("x-dead-letter-exchange",ConfigOfDeadLetterQueue.EXCHANGE_NAME_DLE);
        queue.addArgument("x-dead-letter-routing-key",ConfigOfDeadLetterQueue.Dead_Letter_RoutingKey);
        //queue.addArgument("x-max-priority",ConfigOfDeadLetterQueue.MAX_PRIORITY);
        return queue;
    }
    

    @Bean
    public Binding bindExchangeAndQueueA_PID24a(){
        return BindingBuilder.bind(EAP_REQUEST_QUEUE_PID24a()).to(EXCHANGE_NAME_PID24a())
                .with(EAP_REQUEST_QUEUE_ROUTINGKEY_PID24a);
    }
    @Bean
    public Binding bindExchangeAndQueueB_PID24a(){
        return BindingBuilder.bind(EAP_RESPONSE_QUEUE_PID24a()).to(EXCHANGE_NAME_PID24a())
                .with(EAP_RESPONSE_QUEUE_ROUTINGKEY_PID24a);
    }

    @Bean
    public Binding bindExchangeAndQueueC_PID24a(){
        return BindingBuilder.bind(MES_REQUEST_QUEUE_PID24a()).to(EXCHANGE_NAME_PID24a())
                .with(MES_REQUEST_QUEUE_ROUTINGKEY_PID24a);
    }

    @Bean
    public Binding bindExchangeAndQueueD_PID24a(){
        return BindingBuilder.bind(MES_RESPONSE_QUEUE_PID24a()).to(EXCHANGE_NAME_PID24a())
                .with(MES_RESPONSE_QUEUE_ROUTINGKEY_PID24a);
    }
}